package com.ct.application.system.service.impl;

import com.ct.application.system.model.po.AdminSystemDepartmentSavePO;
import com.ct.application.system.model.vo.AdminSystemDepartmentVO;
import com.ct.application.system.service.IAdminSystemDepartmentService;
import com.ct.repository.convert.CopyConvertUtils;
import com.ct.system.orm.AdminSystemDepartment;
import com.ct.system.responsity.admin.IAdminSystemDepartmentRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 文章表 服务实现类
 * </p>
 *
 * @author Auto Generator
 * @since 2023-08-16
 */
@Service
public class AdminSystemDepartmentServiceImpl implements IAdminSystemDepartmentService {

    @Autowired
    private IAdminSystemDepartmentRepository adminSystemDepartmentRepository;


    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean saveUpdateAdminSystemDepartment(AdminSystemDepartmentSavePO adminSystemDepartmentSavePO) {
        AdminSystemDepartment adminSystemDepartment = CopyConvertUtils.copyProperties(adminSystemDepartmentSavePO, AdminSystemDepartment.class);
        adminSystemDepartment.setDefaultFlag(0);
        boolean b = adminSystemDepartmentRepository.saveOrUpdate(adminSystemDepartment);
        return b;
    }

    @Override
    public boolean deleteAdminSystemDepartmentById(Long id) {
        boolean b =  adminSystemDepartmentRepository.removeById(id);
        return b;
    }


    // 状态修改
    @Override
    public boolean updateStatus(Long id,String column,Integer value){
        boolean b =  adminSystemDepartmentRepository.updateStatus(id,column,value);
        return b;
    }

    @Override
    public boolean updateStatusStr(Long id,String column,String value){
        boolean b =  adminSystemDepartmentRepository.updateStatusStr(id,column,value);
        return b;
    }

    /**
     * 获取部门明细
     * @param id
     * @return
     */
    @Override
    public AdminSystemDepartmentVO getAdminSystemDepartmentById(Long id){
        AdminSystemDepartment adminSystemDepartment = adminSystemDepartmentRepository.getById(id);
        return adminSystemDepartmentRepository.tranferBo(adminSystemDepartment,AdminSystemDepartmentVO.class);
   }

}
